<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class BranchTest extends Model
{
    //关联数据表
    public $table = 'branchtest';

    //主键
    public $primaryKey = "id";

    //允许操作的字段
    public $fillable = ['username','userkey','tel','usersecret','num','successnum','money','successmoney','today','all','ip'];

    //不允许操作的字段
    public $guarded=[];

    //是否维护crated_at和updated_at字段
    public $timestamps = true;

    public function tel($key,$secret){
        $res = $this->where(["userkey"=>$key,"usersecret"=>$secret])->select('tel')->first();
        return $res['tel'];
    }

    public function getId($key,$secret){
        $res = $this->where(["userkey"=>$key,"usersecret"=>$secret])->select('id')->first();
        return $res['id'];
    }

    public function getSecret($key){
        $res = $this->where(["userkey"=>$key])->select('usersecret')->first();
        return $res['usersecret'];
    }
}
